/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * InvulgoTracker
 * Copyright (C) Thomas Andersen 2011 <thomas.1.andersen@gmail.com>
 * 
 * InvulgoTracker is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * InvulgoTracker is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TIME_VIEW_H_
#define _TIME_VIEW_H_

#include <gtk/gtk.h>
#include "i-day-load.h"
#include "taskid.h"
#include "task-time.h"

class TimeView : public IDayLoad
{
public:
    TimeView();
    void Init(GtkWidget *view);
    virtual ~TimeView();
    void Edit(gchar *pathStr, gchar *newStr);
    void Add();
        void Add(TaskId taskId);
    void Add(GtkTreePath *path);
    void AddNoCheck(TaskId taskId, TaskTime tt);
    bool Find(TaskId taskId);
    void Insert();
    void Delete();
    void Load();
    void Save();
    void SetDate(guint year, guint month, guint day) { this->year = year; this->month = month; this->day = day; }
        void Data(gchar *name, gchar *timeStr, TaskId id);
    guint GetYear() { return this->year; }
    guint GetMonth() { return this->month; }
    guint GetDay() { return this->day; }
    GtkWidget *GetCurrentDlg() { return currentDlg; }
    void SetPct(TaskId &id, glong pct);
    void SetColor(TaskId &id, const gchar *color);
protected:

private:
    static gint sort_iter_compare_func (GtkTreeModel *model, GtkTreeIter  *a, GtkTreeIter  *b, gpointer userdata);
    void AppendTask(gchar *name, TaskId taskId);
    void AppendTask(gchar *name, TaskId taskId, TaskTime tt);
    bool Warn();
    bool WarnDelete();
    enum
    {
      COL_TITLE = 0,
      COL_TIME,
      COL_PCT,
      COL_ID,
      COL_COLOR,
      NUM_COLS
    } ;

    GtkTreeModel *CreateModel();

    GtkTreeModel *model;
    GtkTreeView *view;
    gint year, month, day;
    static TimeView *tv;
    GtkWidget *currentDlg;
};

#endif // _TIME_VIEW_H_
